package com.myp.chariotmicro.order.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.myp.chariotmicro.model.response.ApiResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class OrderController {
    @GetMapping("/order")
    @SentinelResource(value = "getOrderNoResource", blockHandler = "getOrderNoBlockHandler", blockHandlerClass = OrderController.class)
    public ApiResponse<String> order() {
        return ApiResponse.success("order controller");
    }

    /**
     * 限流后续操作方法
     * @param e
     * @return
     */
    public static String getOrderNoBlockHandler(BlockException e){
        String msg = "不好意思，前方拥挤，请您稍后再试";
        return msg;
    }
}

